package com.jsn.controller;


import com.jsn.entity.SmartUser;
import com.jsn.responseEntity.R;
import com.jsn.support.BaseController;
import lombok.extern.slf4j.Slf4j;
import org.springframework.security.core.authority.AuthorityUtils;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@RestController
@RequestMapping("/admin")
@Slf4j
public class IndexController extends BaseController {



    @GetMapping("/index")
    public R index() {
          Object principal = SecurityContextHolder.getContext().getAuthentication().getPrincipal();
        System.out.println(principal.getClass());
        if(SecurityContextHolder.getContext().getAuthentication().getPrincipal() instanceof SmartUser){
           SmartUser user = (SmartUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
           System.out.println(user);
       }
        return success();
    }

    @PostMapping("/check")
    public R check(@RequestBody Map map) {

        System.out.println(map);
        return success(map);

    }




}
